local skill = fk.CreateSkill {
  name = "lvshi__support_skill",
}
local ls = require "packages/lvshi/utility"

Fk:loadTranslationTable{
  ["#lvshi__support_skill_throw"] = "你可弃置一张锦囊牌令%src执行两项",
}

skill:addEffect("cardskill", {
  prompt = "#lvshi__support_skill",
  target_num = 1,
  mod_target_filter = Util.TrueFunc,
  target_filter = Util.CardTargetFilter,
  on_use = function(self, room, use)
    local choice = ls.strategytrickuse(use.from, use.card, "support_scheme", "support_courage")
    use.extra_data = use.extra_data or {}
    use.extra_data.strategy = choice
  end,
  on_effect = function(self, room, effect)
    local to = effect.to
    to:addToPile("shield", room:getNCards(1), false, self.name)
    if table.every(room:getOtherPlayers(to), function (p) return p:getHandcardNum() >= to:getHandcardNum() end)
    or effect.extra_data.strategy == "support_scheme" then
      to:drawCards(1, "support")
    end
    if effect.extra_data.strategy == "support_courage" and table.every(room:getOtherPlayers(to), function (p) return p.hp >= to.hp end) then
      room:recover{
        who = effect.to,
        num = 1,
        card = effect.card,
        recoverBy = effect.from,
        skillName = skill.name,
      }
    end
  end,
})

return skill